package com.coderman.modelfly;

import com.coderman.modelfly.service.GenerateBean;
import com.coderman.modelfly.service.impl.GenerateDtoImpl;
import com.coderman.modelfly.service.impl.GenerateEntityImpl;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Parameter;

/**
 * Goal which touches a timestamp file.
 *
 * @author 58
 * @goal modelFly
 *
 * @phase process-sources
 */
public class ModelFlyMojo extends AbstractMojo{

    /**
     * 插件初始化配置文件路径
     * @parameter
     * @required
     */
    private String configPath;

    /**
     * 项目名称
     * @parameter
     * @required
     */
    private String projectName;


    @Override
    public void execute() throws MojoExecutionException, MojoFailureException {
        getLog().info("hello modelfly, take you fly.......");
        try {
            getLog().info("configPath = "+configPath);
            getLog().info("projectName = "+projectName);
            GenerateBean generateBeanEntity = new GenerateEntityImpl(configPath,projectName);
            GenerateBean generateBeanDto = new GenerateDtoImpl(configPath,projectName);

            generateBeanEntity.generateBeanFromTable();
            generateBeanDto.generateBeanFromTable();
        } catch (Exception e) {
            e.printStackTrace();
            getLog().error("modelfly error,"+e.getMessage());
        }

    }
}
